package nc.ui.cmp.applaybill.command;

import nc.ui.cmp.applaybill.ClientUI;
import nc.ui.cmp.applaybill.common.UIUtil;
import nc.ui.pub.ButtonObject;
import nc.ui.trade.base.IBillOperate;
import nc.ui.trade.bocommand.IButtonCommand;
import nc.ui.trade.controller.IControllerBase;
import nc.ui.trade.manage.BillManageUI;
import nc.ui.trade.manage.ManageEventHandler;
import nc.vo.cmp.applaybill.AggApplyBillVO;
import nc.vo.cmp.applaybill.ApplyBillVO;
import nc.vo.pub.AggregatedValueObject;

public class CardBoCommand extends ManageEventHandler implements IButtonCommand {

	public CardBoCommand(BillManageUI billUI, IControllerBase control) {
		super(billUI, control);
		// TODO Auto-generated constructor stub
	}

	public void execute(ButtonObject bo) throws Exception {
		ClientUI clientUI = (ClientUI)getBillUI();
		int row = clientUI.getBillListPanel().getHeadTable().getSelectedRow();
		AggregatedValueObject billValueVO = null;
		if(row != -1) {
			billValueVO = clientUI.getBillListPanel().getBillListData().getBillValueVO(row, AggApplyBillVO.class.getName(), ApplyBillVO.class.getName(), ApplyBillVO.class.getName());
		}
		super.onBoCard();
		if(billValueVO != null) {
			UIUtil.changeCardTemplet((ApplyBillVO) billValueVO.getParentVO(), clientUI);
			UIUtil.updateButtonsByBean((ApplyBillVO) billValueVO.getParentVO(), clientUI);
		}else {
			clientUI.setBillOperate(IBillOperate.OP_INIT);
		}
		getBillCardPanelWrapper().setCardData(billValueVO);
		clientUI.getBillCardPanel().setEnabled(false);
	}

}
